package conf

import (
	"flag"
	"github.com/titanous/json5"
	"os"
)

var Config = &config{}

func init() {
	configFile := flag.String("config", "config.json5", "Path to the configuration file")
	flag.Parse()

	b, err := os.ReadFile(*configFile)
	if err != nil {
		panic("Sys config read err")
	}
	err = json5.Unmarshal(b, Config)
	if err != nil {
		panic(err)
	}
}

type db struct {
	Type     string `json:"type"`
	Host     string `json:"host"`
	Port     string `json:"port"`
	Database string `json:"database"`
	User     string `json:"user"`
	Password string `json:"password"`
}

type config struct {
	//数据库配置
	DBSrc    db       `json:"db_src"`
	DBDst    db       `json:"db_dst"`
	TbOnly   []string `json:"tb_only"`
	TbIgnore []string `json:"tb_ignore"`
}
